/*
 * @lc app=leetcode.cn id=746 lang=javascript
 *
 * [746] 使用最小花费爬楼梯
 */

// @lc code=start
/**
 * @param {number[]} cost
 * @return {number}
 */
var minCostClimbingStairs = function (cost) {
  let dp = [];

  dp[1] = 0;

  dp[2] = Math.min(cost[0], cost[1]);

  for (let i = 3; i <= cost.length; i++) {
    dp[i] = Math.min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);
  }
  console.log(dp);
  return dp[cost.length];
};

let cost = [10, 15, 20, 25];
let res = minCostClimbingStairs(cost);
console.log("🚀 ～ file: 746.使用最小花费爬楼梯.js:27 ～ res:", res);
// @lc code=end
